package panel;

import panel.role.xmlgenerate.XmlGeneratePanel;
import util.BeanManager;

import javax.swing.*;
import java.awt.*;

/**
 * 主面板
 */
public class ApplicationPanel extends JPanel {
	private JPanel currentPanel;

	public ApplicationPanel() {
		setLayout(new BorderLayout());

		// 默认第一个
		switchContentPanel(BeanManager.getBean(XmlGeneratePanel.class));
	}

	public void switchContentPanel(JPanel newPanel) {
		if (currentPanel == newPanel) return;
		if (currentPanel != null) {
			remove(currentPanel);
		}

		this.currentPanel = newPanel;
		add(newPanel);
		validate();
		newPanel.repaint();
	}
}
